"use strict";
    function _classCallCheck(e, n) {
        if (!(e instanceof n))
            throw new TypeError("Cannot call a class as a function")
    }
    var _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (e) {
                return typeof e
            } : function (e) {
                return e && "function" == typeof Symbol && e.constructor === Symbol ? "symbol" : typeof e
            },
            _createClass = function () {
                function e(e, n) {
                    for (var t = 0; t < n.length; t++) {
                        var i = n[t];
                        i.enumerable = i.enumerable || !1, i.configurable = !0, "value" in i && (i.writable = !0), Object.defineProperty(e, i.key, i)
                    }
                }

                return function (n, t, i) {
                    return t && e(n.prototype, t), i && e(n, i), n
                }
            }(),
            APPSTORE_URI = "https://itunes.apple.com/cn/app/nan-yi-ku/id1170088301?mt=8",
            ANDROID_APK_URI = "https://www.nanyiku.com/app/nanyiku.apk",
            YINGYONG_BAO = "http://a.app.qq.com/o/simple.jsp?pkgname=com.nanyiku",
            browser = {
                versions: function () {
                    var e = navigator.userAgent;
                    return navigator.appVersion, {
                        trident: e.indexOf("Trident") > -1,
                        presto: e.indexOf("Presto") > -1,
                        webKit: e.indexOf("AppleWebKit") > -1,
                        gecko: e.indexOf("Gecko") > -1 && -1 == e.indexOf("KHTML"),
                        mobile: !!e.match(/AppleWebKit.*Mobile.*/),
                        ios: !!e.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/),
                        android: e.indexOf("Android") > -1 || e.indexOf("Linux") > -1,
                        iPhone: e.indexOf("iPhone") > -1,
                        iPad: e.indexOf("iPad") > -1,
                        webApp: -1 == e.indexOf("Safari"),
                        weixin: e.indexOf("MicroMessenger") > -1,
                        qq: " qq" == e.match(/\sQQ/i),
                        weibo: e.indexOf("_weibo_") > -1,
                        nanyiku: e.indexOf("nanyiku") > -1
                    }
                }(),
                language: (navigator.browserLanguage || navigator.language).toLowerCase(),
                nanyikuVersion: function () {
                    var e = navigator.userAgent,
                            n = "nanyiku/";
                    return e.indexOf(n) > -1 ? e.substring(e.indexOf(n) + n.length) : ""
                }()
            },
            compareVersion = function (e, n) {
                Math.sign || function () {
                    Math.sign = function (e) {
                        return e > 0 ? 1 : 0 > e ? -1 : e
                    }
                }();
                var t = function i(e, n) {
                    return e.length || n.length ? (parseInt(e.pop()) || 0) - (parseInt(n.pop()) || 0) || i(e, n) : 0
                };
                return Math.sign(t(e.split(".").reverse(), n.split(".").reverse()))
            },
            downloadApp = function () {
                if (browser.versions.weixin) window.location.href = YINGYONG_BAO;
                else if (browser.versions.ios)
                    if (browser.versions.weibo) {
                        var e = new OpenBrowser;
                        e.showTip("点击右上角菜单,选择safari打开")
                    } else window.location.href = APPSTORE_URI;
                else browser.versions.android ? window.location.href = ANDROID_APK_URI : window.location.href = "https://www.nanyiku.com/"
            },
            NativeHref = function () {
                function e() {
                    _classCallCheck(this, e)
                }

                return _createClass(e, null, [{
                    key: "href",
                    value: function (e, n) {
                        var t = "" + e;
                        t = t.replace(/(^[^\w]*)/g, ""), t = t.replace(/([&?]*$)/g, ""), t.indexOf("://") < 0 && (t = "nanyiku://" + t);
                        var i = t.indexOf("?") > 0 ? "&" : "?";
                        if ("string" == typeof n) n = n.replace(/(^[&?]*)/g, ""), "" !== n && (t = t + i + n);
                        else if ("object" === ("undefined" == typeof n ? "undefined" : _typeof(n)) && void 0 !== n && null !== n) {
                            var o = [],
                                    a = function (e, n) {
                                        o.push(encodeURIComponent(e) + "=" + encodeURIComponent(n))
                                    };
                            for (var r in n)
                                if (n.hasOwnProperty(r)) {
                                    var s = n[r];
                                    "boolean" == typeof s ? a(r, s ? "1" : "0") : "number" == typeof s ? a(r, s) : "string" == typeof s ? "" !== s && a(r, s) : "object" === ("undefined" == typeof s ? "undefined" : _typeof(s)) && void 0 != s && null != s && a(r, JSON.stringify(s))
                                }
                            var l = o.join("&");
                            "" !== l && (t = t + i + l)
                        }
                        return t
                    }
                }, {
                    key: "jump",
                    value: function (e, n) {
                        var t = this.href(e, n);
                        if (0 == t.indexOf("http:") || 0 == t.indexOf("https:")) window.location.href = t;
                        else if (t.length > 0) {
                            var i;
                            i = document.createElement("iframe"), i.setAttribute("src", t), i.setAttribute("style", "display:none;"), i.setAttribute("height", "0px"), i.setAttribute("width", "0px"), i.setAttribute("frameborder", "0"), document.body.appendChild(i), i.parentNode.removeChild(i), i = null
                        }
                    }
                }]), e
            }(),
            OpenBrowser = function () {
                function e() {
                    _classCallCheck(this, e)
                }

                return _createClass(e, [{
                    key: "showTip",
                    value: function (e) {
                        var n = document.createElement("div");
                        n.className = "openBrowser hide";
                        var t = document.createElement("div");
                        t.className = "openBrowser-icon", t.innerHTML = '\n<svg width="70px" height="50px" viewBox="0 0 70 50" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:sketch="http://www.bohemiancoding.com/sketch/ns">\n    <g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd" sketch:type="MSPage">\n        <g id="open_in_browser" sketch:type="MSArtboardGroup" fill="#F4D86C">\n            <path d="M-1.15644029e-16,48.7257062 C34.999998,56.9588058 62.3894668,22.6032939 62.3894668,22.6032939 L70,26.346293 L63.4775021,7.10542736e-15 L39.6373529,12.2554815 L48.2087417,16.1774604 C48.2087417,16.1774604 35.8816856,43.1823029 -1.15644029e-16,48.7257062 Z" id="Path-1" sketch:type="MSShapeGroup"></path>\n        </g>\n    </g>\n</svg>\n        ', n.appendChild(t);
                        var i = document.createElement("div");
                        return i.className = "openBrowser-text", i.innerText = e, n.appendChild(i), document.body.appendChild(n), setTimeout(function () {
                            n.classList.remove("hide"), n.addEventListener("click", function () {
                                this.hideTip(n)
                            })
                        }, 100), n
                    }
                }, {
                    key: "hideTip",
                    value: function (e) {
                        if (e) {
                            var n = function () {
                                e && e.parentNode && e.parentNode.removeChild(e)
                            };
                            e.classList.remove("show"), e.classList.add("hide"), e.addEventListener("transitionend", n), setTimeout(n, 500)
                        }
                    }
                }]), e
            }(),
            JSAlert = function () {
                function e() {
                    _classCallCheck(this, e)
                }

                return _createClass(e, [{
                    key: "showTip",
                    value: function (e) {
                        var n = this,
                                t = document.createElement("div");
                        t.className = "native-alert hide";
                        var i = document.createElement("div");
                        i.className = "native-alert-text", t.appendChild(i);
                        var o = document.createElement("span");
                        return o.innerText = e, i.appendChild(o), document.body.appendChild(t), setTimeout(function () {
                            t.classList.remove("hide"), setTimeout(function () {
                                n.hideTip(t)
                            }, 1800)
                        }, 100), t
                    }
                }, {
                    key: "hideTip",
                    value: function (e) {
                        if (e) {
                            var n = function () {
                                e && e.parentNode && e.parentNode.removeChild(e)
                            };
                            e.classList.remove("show"), e.classList.add("hide"), e.addEventListener("transitionend", n), setTimeout(n, 500)
                        }
                    }
                }]), e
            }(),
            HKLoadMore = function () {
                function e(n, t, i, o, a) {
                    var r = this,
                            s = arguments.length <= 5 || void 0 === arguments[5] ? 8 : arguments[5];
                    _classCallCheck(this, e), this.url = n, this.params = t || {}, this.success = i, this.failed = o, this.showLoadingCallback = a, this.page = 1, this.isLoading = !1, this.countInPrePage = s, this.request = window.HKRequest && window.HKRequest.GET, this.dataKey = void 0, this.footerHeight = 0, this.scrollCallback = function () {
                        if (!r.isLoading) {
                            var e = $(window).scrollTop(),
                                    n = $(document).height(),
                                    t = $(window).height();
                            e + t >= n - r.footerHeight && r.loadMoreAction()
                        }
                    }
                }

                return _createClass(e, [{
                    key: "setRequestMethon",
                    value: function (e) {
                        "ajax" === e && (this.request = function (e, n, t, i) {
                            $.ajax({
                                url: e,
                                data: n,
                                dataType: "json",
                                success: t,
                                error: i
                            })
                        })
                    }
                }, {
                    key: "loadMoreAction",
                    value: function () {
                        var e = this;
                        this.isLoading && "function" == typeof this.request || (this.showLoading(!0), console.log("url:", this.url), this.request(this.url, $.extend({
                            page: this.page
                        }, this.params), function (n) {
                            var t = n.data;
                            "string" == typeof e.dataKey && (t = t[e.dataKey]), t instanceof Array ? (1 == e.page && t.length >= e.countInPrePage ? $(window).unbind("scroll", e.scrollCallback).bind("scroll", e.scrollCallback) : 1 != e.page && t.length < e.countInPrePage && $(window).unbind("scroll", e.scrollCallback), e.success && e.success(n), e.page += 1, e.countInPrePage = t.length) : e.failed && e.failed("data format error"), window.setTimeout(function () {
                                e.showLoading(!1)
                            }, 800)
                        }, function (n) {
                            e.failed && e.failed(n), window.setTimeout(function () {
                                e.showLoading(!1)
                            }, 800)
                        }))
                    }
                }, {
                    key: "showLoading",
                    value: function (e) {
                        console.log("isloading:", e), this.isLoading = e, this.showLoadingCallback && this.showLoadingCallback(e)
                    }
                }]), e
            }();
  /*  $.fn.extend({
        frame: function () {
            var e = this.offset() || {};
            return [e.left - $(window).scrollLeft() || 0, e.top - $(window).scrollTop() || 0, this.width() || 0, this.height() || 0]
        },
        frameStr: function () {
            var e = this.frame(),
                    n = function (e, n) {
                        return "{" + e + "," + n + "}"
                    };
            return n(n(e[0], e[1]), n(e[2], e[3]))
        }
    });*/

    $(function () {
        browser.versions.nanyiku || $(".download_area").css({
            display: "block"
        })
    }), browser.versions.nanyiku || !function (a, n) {
        var e = n.createElement("script"),
                i = n.getElementsByTagName("head")[0];
        a.alimamatk_show || (e.charset = "gbk", e.async = !0, e.src = "http://a.alimama.cn/tkapi.js", i.insertBefore(e, i.firstChild));
        var o = {
            //pid: "mm_29422230_12866703_56080285",
            pid: "mm_29422230_14384167_56862237",
            //pid: "mm_115824338_14282967_56654789",
            appkey: "",
            unid: "",
            type: "click"
        };
        a.alimamatk_onload = a.alimamatk_onload || [], a.alimamatk_onload.push(o)
    }(window, document);